//
//  Constants.h
//  SISSAPP
//
//  Created by 优房网 on 2017/3/21.
//  Copyright © 2017年 优房网. All rights reserved.
//

#ifndef Constants_h
#define Constants_h

// 设备尺寸
#define SCREEN_BOUNDS   [UIScreen mainScreen].bounds
#define SCREEN_WIDTH    [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT   [UIScreen mainScreen].bounds.size.height
// 屏幕缩放比
#define MAIN_SCALE [UIScreen mainScreen].scale

//判断设备型号
#define UI_IS_LANDSCAPE   ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft || [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight)
#define UI_IS_IPAD        ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define UI_IS_IPHONE      ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define UI_IS_IPHONE4     (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height < 568.0)
#define UI_IS_IPHONE5     (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define UI_IS_IPHONE6     (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define UI_IS_IPHONE6PLUS (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0 || [[UIScreen mainScreen] bounds].size.width == 414.0) // Both orientations
#define UI_IS_IPHONE_X    (UI_IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 812.0)
#define UI_IS_IOS8_AND_HIGHER   ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)

#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS10Later ([UIDevice currentDevice].systemVersion.floatValue >= 10.0f)

// 应用的bundle
#define BUNDLE_ID [NSBundle mainBundle].bundleIdentifier

/// 常用宏定义
#define kUserDefaults       [NSUserDefaults standardUserDefaults]
#define kNotificationCenter [NSNotificationCenter defaultCenter]
#define kApplication        [UIApplication sharedApplication]
#define kAppDelegate        (AppDelegate *)[[UIApplication sharedApplication] delegate]
#define kFileManager        [NSFileManager defaultManager]
#define kBundle             [NSBundle mainBundle]
#define kDevice             [UIDevice currentDevice]
#define kWindow             [[UIApplication sharedApplication] keyWindow]
#define kInfoDictionary     [[NSBundle mainBundle] infoDictionary]
#define kBundleVersion      [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
#define kBundleVersionStr   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
#define kDocumentPath       [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kBundleLoadNibName(name) [[[NSBundle mainBundle] loadNibNamed:name owner:nil options:nil] lastObject]


/** 颜色 */
#define COLOR(hex) [UIColor colorWithRed:((hex&0xff0000)>>16)/255.0 green:((hex&0x00ff00)>>8)/255.0 blue:((hex&0xff)>>0)/255.0 alpha:1]                 //十六进制颜色宏
#define COLOR_ALPHA(hex,a) [UIColor colorWithRed:((hex&0xff0000)>>16)/255.0 green:((hex&0x00ff00)>>8)/255.0 blue:((hex&0xff)>>0)/255.0 alpha:a]   //十六进制颜色宏，带透明度
#define MAIN_COLOR COLOR(0x33A3BB)
#define MAIN_TEXT_COLOR COLOR(0x334A60)
#define SECONDARY_TEXT_COLOR COLOR(0x8998A5)
// 返回一个RGBA格式的UIColor对象
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
// 返回一个RGB格式的UIColor对象
#define RGB(r, g, b) RGBA(r, g, b, 1.0f)

// 字体大小
#define FONT(fontSize) [UIFont systemFontOfSize:fontSize]

/// 导航栏高度
#define NAVIGATION_HEIGHT (CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) + CGRectGetHeight(self.navigationController.navigationBar.frame))
#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
#define kNavBarHeight 44.0
#define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 83 : 49)
#define kTopHeight (kStatusBarHeight + kNavBarHeight)

#define WeakSelf __weak __typeof(&*self)weakSelf = self;

//是否是空对象
#define SISSIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

static const CGFloat globelMargin = 8.0;

// 日志输出
//#ifdef __OBJC__
//#ifdef DEBUG
//#define NSLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
//#else
//#define NSLog(...)
//#endif
//#endif

#ifdef DEBUG
#define NSLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
#else
#define NSLog(format, ...)
#endif

// 打印NSInteger类型
//#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
//typedef long NSInteger;
//typedef unsigned long NSUInteger;
//#else
//typedef int NSInteger;
//typedef unsigned int NSUInteger;
//#endif

// 协会公告、系统通知枚举 
typedef NS_ENUM(NSInteger, SISSNotificationType) {
    SISSNotificationTypeNoticeRecord, // 协会公告
    SISSNotificationTypeSystemMessage // 系统通知
};

/// 返回进度控制器枚举
typedef enum : NSUInteger {
    SISSProgressPopBackClassTypeHouse,
    SISSProgressPopBackClassTypePassenger,
    SISSProgressPopBackClassTypeRentOut,
    SISSProgressPopBackClassTypeTenant,
    SISSProgressPopBackClassTypeHouseCooperation,
    SISSProgressPopBackClassTypePassengerCooperation
} SISSProgressPopBackClassType;

#endif /* Constants_h */
